package com.itproject.manager.es.config;


import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticsearchConfig {
    @Bean
    public RestHighLevelClient highLevelClient() {
        // 如果是集群就配置多个, 如果不是集群就只配置一个
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.1.104", 9200, "http"),
                        new HttpHost("192.168.1.106", 9200, "http"),
                        new HttpHost("192.168.1.10", 9200, "http")
                )
        );
        return client;
    }

}